package com.ybkj.chat.module.mine.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;

import com.ybkj.chat.R;
import com.ybkj.chat.base.BaseMvpActivity;
import com.ybkj.chat.ui.dialog.PpwClearCache;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author yyj
 * @create 2019-02-21 10:05
 * @Describe 设置
 */
public class SettingsActivity extends BaseMvpActivity {

    @BindView(R.id.lnl_root)
    LinearLayout lnlRoot;

    private PpwClearCache ppwClearCache;

    @Override
    protected void injectPresenter() {

    }

    @Override
    protected void initTitle() {
        setTitleText("设置");
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_settings;
    }

    @Override
    protected void initView() {
        initClearCache();
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.lnl_account_safe, R.id.lnl_message_notice, R.id.lnl_privacy, R.id.lnl_clear_cache, R.id.lnl_help, R.id.lnl_logout})
    public void onViewClicked(View view) {
        Intent intent = new Intent(this, MultiUseActivity.class);
        switch (view.getId()) {
            case R.id.lnl_account_safe:
                intent.putExtra("title", "账号安全");
                startActivity(intent);
                break;
            case R.id.lnl_message_notice:
                intent.putExtra("title", "消息通知");
                startActivity(intent);
                break;
            case R.id.lnl_privacy:
                intent.putExtra("title", "隐私设置");
                startActivity(intent);
                break;
            case R.id.lnl_clear_cache:
                ppwClearCache.showAtLocation(lnlRoot, Gravity.BOTTOM,0,0);
                ppwClearCache.setBackgroundAlpha(this,0.5f);
                break;
            case R.id.lnl_help:
                break;
            case R.id.lnl_logout:
                break;
        }
    }

    private void initClearCache() {
        ppwClearCache = new PpwClearCache(this);
        ppwClearCache.setAnimationStyle(R.style.choose_item_dialog_animation);
        ppwClearCache.setOnItemClickListener(new PpwClearCache.OnItemClickListener() {
            @Override
            public void onItemClick(View v) {
                switch (v.getId()) {
                    case R.id.tv_clear:
                        ppwClearCache.dismiss();
                        break;
                    case R.id.tv_cancel:
                        ppwClearCache.dismiss();
                        break;
                }
            }
        });
    }
}
